<?php
/* @var $this QShiftController */

$this->pageTitle=Yii::app()->name . ' - My Shifts';
$this->breadcrumbs=array(
	'Q-Shifts'=>array('/qshift/'),
	'My Q-Shifts',
);


// DATE PROCESSING
$dateObject = new DateTime('NOW');
$dateObject->setTimeZone(new DateTimeZone("America/Costa_Rica"));
$week  = $dateObject->format('W');
$year = $dateObject->format('Y');	
$timestamp = strtotime($dateObject->format('Y-m-d'));
$mondayDate = date('Y-m-d',strtotime(date('o-\\WW')));
$sundayDate = date('Y-m-d', strtotime('sunday',strtotime(date('o-\\WW'))));
?>

<h1>My Q-Shifts</h1>
<br>

<p>
<center><h2>My Q-Shifts For Week <?php echo $week." - ".$year; ?> </h2>
<br>
<h3>from <?php echo $mondayDate;?> thru <?php echo $sundayDate;?></h3></center>


<?php 
	
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'id',
	'dataProvider'=>$model->getUserWeekSchedule($model->iduser,null,$week,$year),
	'summaryText' => '',
	'enableSorting' => false,
	'columns'=>array(
		array(
			'name'=>'weekday',
			'header'=>'Weekday',
			'value'=>'$data->weekday_relation->name',
			'htmlOptions' => array(
								'style' => 'width:84px; text-align:center;',
							 ),
		),	
		array(
			'name'=>'qshift',
			'header'=>'Q-Shift',
			'value'=>'$data->qshift_relation->name',
			'htmlOptions' => array(
								'style' => 'width:90px; text-align:center;',
							 ),
		),	
		array(
			'name'=>'qshift_start_time',
			'header'=>'Start Time',
			'value'=>'$data->qshift_relation->start_time',
			'htmlOptions' => array(
								'style' => 'width:70px; text-align:center;',
							 ),
		),		
		array(
			'name'=>'qshift_end_time',
			'header'=>'End Time',
			'value'=>'$data->qshift_relation->end_time',
			'htmlOptions' => array(
								'style' => 'width:70px; text-align:center;',
							 ),
		),	
		array(
			'class'=>'CButtonColumn',
			'header'=>'Changes',
			'template'=>'{view}',
			'buttons'=>array(
						'view'=>array(
									'url'=>'Yii::app()->createUrl("shiftChange/view", array("id"=>$data->changeId))',
									'label'=>'Shift Change',
									'visible'=> '$data->wasChanged',
									'options' => array('style'=>'width:40px;','title'=>'Swapped! Click for details','target'=>'_blank')
						          ),
						
					   ),			
		),		
	),
)); ?>

<br>

<center><h2>My Permanent Q-Shifts </h2></center>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'schedule-grid',
	'dataProvider'=>$model->search($model->iduser),
	'summaryText' => '',
	'enableSorting' => false,
	'columns'=>array(
		array(
			'name'=>'weekday',
			'header'=>'Weekday',
			'value'=>'$data->weekday_relation->name',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),		
		array(
			'name'=>'qshift',
			'header'=>'Q-Shift',
			'value'=>'$data->qshift_relation->name',
			'htmlOptions' => array(
								'style' => 'width:90px; text-align:center;',
							 ),
		),	
		array(
			'name'=>'qshift_start_time',
			'header'=>'Start Time',
			'value'=>'$data->qshift_relation->start_time',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),		
		array(
			'name'=>'qshift_end_time',
			'header'=>'End Time',
			'value'=>'$data->qshift_relation->end_time',
			'htmlOptions' => array(
								'style' => 'width:50px; text-align:center;',
							 ),
		),	
	),
)); ?>

